package com.gyyx.cn.transaction.test.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gyyx.cn.transaction.test.bean.Account2;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author: 王海新
 * @date: 2021/12/9/0009 15:38
 * @version: 1.0
 * @description: TODO
 */
@Repository
@Mapper
public interface Account2Dao extends BaseMapper<Account2> {
    /**
     *付款
     * @param money
     * @param fromCardNo
     */
    @Update("update account set money = money - #{money} where cardNo = #{fromCardNo}")
    void fromCard(@Param("money") Integer money, @Param("fromCardNo") String fromCardNo);

    /**
     * 收款
     * @param money
     * @param toCardNo
     */
    @Update("update account set money = money + #{money} where cardNo = #{toCardNo}")
    void toCard(@Param("money") Integer money, @Param("toCardNo") String toCardNo);
}
